package com.hawthorn.redis.controller;

import com.hawthorn.entity.po.SysCompanyPO;
import com.hawthorn.redis.service.company.CompanyCacheService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>todo 系统公司缓存</p>
 * @author: andy.ten@tom.com | xukaixing@hotmail.com
 * @created: 2022/06/30 12:25 PM
 * @version v1.0.1
 * @copyright: Copyright (c)  andyten
 */
@Api(tags = {"redis-syscompany"})
@RestController
@RequestMapping("/company")
@Slf4j
public class CompanyCacheController
{
  @Autowired
  private CompanyCacheService companyCacheService;

  /**
   * <p>todo 重新加载系统公司</p>
   * @author: andy.ten@tom.com
   * @date: 2022/06/30 12:36 PM
   * @version: 1.0.1
   */
  @ApiOperation(value = "加载->重新初始化系统公司", notes = "重新初始化系统公司")
  @ApiImplicitParams({
  })
  @GetMapping(value = "reloadCompany")
  public void reloadCompany()
  {
    companyCacheService.init();
  }

  /**
   * <p>todo 根据po重新加载公司</p >
   * @author: WCZ
   * @date: 2022/7/20 16:45
   * @version: 1.0.1
   */
  @ApiOperation(value = "加载->根据po重新加载公司", notes = "根据po重新加载公司")
  @ApiImplicitParams({
      @ApiImplicitParam(name = "sysCompanyPO", value = "sysCompanyPO", dataTypeClass = SysCompanyPO.class)
  })
  @PostMapping(value = "/cacheCompanyById")
  public void cacheCompanyById(@RequestBody List<SysCompanyPO> companyPOList)
  {
    companyCacheService.cacheCompanyById(companyPOList);
  }
}
